import { FC, ReactNode } from 'react';

import { BoxBasicInfo } from './BatteryBox';
import { CabinetBasicInfo } from './Cabinet';
import { ChargePileBasicInfo } from './ChargePile';
import { InverterBasicInfo } from './Inverter';
import { LcBasicInfo } from './LC';
import { MeterBasicInfo } from './Meter';
import { PcsBasicInfo } from './PCS';
import { useSelectedDeviceNode } from './SelectedDeviceNodeContext';
import { StationBasicInfo } from './Station';
import { AreaBasicInfo } from './Subarea';
import { TransformerBasicInfo } from './Transformer';

export const BasicInfo: FC = () => {
  const node = useSelectedDeviceNode();
  const type = node?.deviceType ?? node?.nodeType;
  const nodeType = node?.nodeType; // 获取 nodeType
  let renderContent: ReactNode = null;
  console.log('nodeType---', nodeType);
  switch (type) {
    case 'STATION':
    case 'ROOT':
      if (nodeType === 'STATION' || nodeType === 'ROOT') {
        renderContent = <StationBasicInfo />;
      }
      break;
    case 'AREA':
      if (nodeType === 'AREA') {
        renderContent = <AreaBasicInfo />;
      }
      break;
    case 'BOX':
      if (nodeType === 'DEVICE_GROUP') {
        renderContent = <BoxBasicInfo />;
      } else if (nodeType === 'DEVICE') {
        renderContent = <CabinetBasicInfo />;
      }
      break;
    // case 'STACK':
    //   if (nodeType === 'DEVICE') {
    //     renderContent = <StackRealtimeInfo />;
    //   }
    //   break;
    // case 'CLUSTER':
    //   if (nodeType === 'DEVICE') {
    //     renderContent = <ClusterRealtimeInfo />;
    //   }
    //   break;
    // case 'MODULE':
    //   if (nodeType === 'DEVICE') {
    //     renderContent = <ModuleRealtimeInfo />;
    //   }
    //   break;
    // case 'BMU':
    //   if (nodeType === 'DEVICE') {
    //     renderContent = <ModuleRealtimeInfo />;
    //   }
    //   break;
    case 'PCS':
      if (nodeType === 'DEVICE') {
        renderContent = <PcsBasicInfo />;
      }
      break;
    case 'GLC':
      if (nodeType === 'DEVICE') {
        // renderContent = <StackRealtimeInfo />;
      }
      break;
    case 'LC':
      if (nodeType === 'DEVICE') {
        renderContent = <LcBasicInfo />;
      }
      break;
    case 'CABINET':
      if (nodeType === 'DEVICE') {
        renderContent = <CabinetBasicInfo />;
      }
      break;
    case 'PCS_CONT':
      if (nodeType === 'DEVICE') {
        renderContent = <LcBasicInfo />;
      }
      break;
    case 'METER':
      if (nodeType === 'DEVICE') {
        renderContent = <MeterBasicInfo />;
      }
      break;
    case 'TRANSFORMER':
      if (nodeType === 'DEVICE') {
        renderContent = <TransformerBasicInfo />;
      }
      break;
    case 'CHARGE_PILE':
      if (nodeType === 'DEVICE') {
        renderContent = <ChargePileBasicInfo />;
      }
      break;
    case 'INVERTER':
      if (nodeType === 'DEVICE') {
        renderContent = <InverterBasicInfo />;
      }
      break;
    default:
      break;
  }

  return renderContent;
};
